<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/1 0001
 * Time: 17:20
 */

namespace app\data\controller;


use think\Db;
use think\Request;
class Edition extends Base
{
    public function index(){
        $data = Request::instance()->get();
        $type = isset($data['type']) ? $data['type'] : 1;
        $field = $type == 1 ? 'no,num,url,time,content' : 'no,time,content,url';
        $list = Db::name('edition')
            ->field($field)
            ->where(['type'=>$type])
            ->order('time desc')
            ->find();
        return $this->returnSuccess($list);
    }


    public function jpushlog(){
        $path = ROOT_PATH .'/public/jpush.log';
        $a= fopen($path,'w+');
        //fwrite($a,'');
        fclose($a);
    }


    public function jpush(){
        $txt = 'Send POST https://api.jpush.cn/v3/push, body:{"platform":"all","audience":{"registration_id":["140fe1da9ee781a8694"]},"notification":{"alert":"\u57fa\u4e8e\u5927\u6570\u636e\u4eba\u5de5\u667a\u80fd\u9884\u6d4b\u4eca\u5929\u66b4\u6da8\u5f00\u7a7a\u4ef7 106.28\uff0c\u9002\u91cf\u5f00\u7a7a\u4ef7 99.13\uff0c\u5c11\u91cf\u5f00\u7a7a\u4ef7 94.67\uff0c\u5c11\u91cf\u5f00\u591a\u4ef7 87.97\uff0c\u9002\u91cf\u5f00\u591a\u4ef7 82.88\uff0c\u66b4\u8dcc\u5f00\u591a\u4ef7 78.54\u3002","android":{"title":"Huobi-LTC \u6b21\u5468 \u5408\u7ea6\u63d0\u9192","alert":"\u57fa\u4e8e\u5927\u6570\u636e\u4eba\u5de5\u667a\u80fd\u9884\u6d4b\u4eca\u5929\u66b4\u6da8\u5f00\u7a7a\u4ef7 106.28\uff0c\u9002\u91cf\u5f00\u7a7a\u4ef7 99.13\uff0c\u5c11\u91cf\u5f00\u7a7a\u4ef7 94.67\uff0c\u5c11\u91cf\u5f00\u591a\u4ef7 87.97\uff0c\u9002\u91cf\u5f00\u591a\u4ef7 82.88\uff0c\u66b4\u8dcc\u5f00\u591a\u4ef7 78.54\u3002"},"ios":{"sound":"ring.aac","alert":"\u57fa\u4e8e\u5927\u6570\u636e\u4eba\u5de5\u667a\u80fd\u9884\u6d4b\u4eca\u5929\u66b4\u6da8\u5f00\u7a7a\u4ef7 106.28\uff0c\u9002\u91cf\u5f00\u7a7a\u4ef7 99.13\uff0c\u5c11\u91cf\u5f00\u7a7a\u4ef7 94.67\uff0c\u5c11\u91cf\u5f00\u591a\u4ef7 87.97\uff0c\u9002\u91cf\u5f00\u591a\u4ef7 82.88\uff0c\u66b4\u8dcc\u5f00\u591a\u4ef7 78.54\u3002","badge":"+1"}},"options":{"sendno":1343721227,"apns_production":true}}, times:1';
        $path = ROOT_PATH .'/public/jpush.log';
        $a = fopen($path,'w+');
        fwrite($a,$txt);
        fclose($a);
    }
}